# encoding:utf-8
from flask import Flask
from flask_login import LoginManager
from flask_pymongo import PyMongo
from apps.db_config import MongoDB, Secret

__author__ = "adog"

# 创建flask实例对象
app = Flask(__name__)

# 创建对象
mongo = PyMongo()
login_manger = LoginManager()
login_manger.session_protection = 'strong'


# app加载配置
app.config.from_object(MongoDB)
app.config.from_object(Secret)

# 初始化mongo我们数据库库配置变量的前缀都是MONGO
#app.config['MONGO_URI']="mongodb://127.0.0.1:27017/userDB"
mongo.init_app(app)
login_manger.init_app(app)

login_manger.login_view = 'adog_api.noPermission'
login_manger.login_message = '请登录以访问此页面'  # 定义需要登录访问页面的提示消息 

# 注册蓝本
from apps.blueprint import api, view,adog_api
app.register_blueprint(view, url_prefix="")
app.register_blueprint(api, url_prefix="/api")
app.register_blueprint(adog_api, url_prefix="/adog_api")


